package com.jydw.da.frame.controller;

import com.jydw.da.frame.pojo.User;
import com.jydw.da.frame.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * (user)表控制层
 *
 * @author xxxxx
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
    /**
     * 服务对象
     */
    @Resource
    private UserService userService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public User selectOne(Integer id) {
        return userService.getById(id);
    }

    @GetMapping("/add")
    public Object add() {

        for (int i = 100; i < 150; i++) {
            User user = new User();
            user.setUsername("forezp" + (i));
            user.setPassword("1233edwd");
            long result = userService.insertOrUpdate(user);
            log.info("insert:" + user.toString() + " result:" + result);
        }
        return "ok";
    }

}
